package com.hotelsystem.dao;

import com.hotelsystem.pojo.OrderDetail;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderDetailMapper {

    /**
     * 添加订单明细
     * @param orderDetail
     * @return
     * @throws Exception
     */
    @Insert("insert into t_orderDetail values(null,#{orders.ordersId},#{goodsName},#{goodsPrice},#{checkInDuration},#{price})")
    Integer insert(OrderDetail orderDetail) throws Exception;

    /**
     * 删除订单明细
     * @param ordersId 订单编号
     * @return
     */
    @Delete("delete from t_orderdetail where orders_id = #{ordersId}")
    Integer delete(String ordersId);

    /**
     * 修改订单明细
     * @param orderDetail
     * @return
     * @throws Exception
     */
    @Update("update t_orderdetail set goods_name = #{goodsName},goods_price=#{goodsPrice},check_in_duration=#{checkInDuration},price=#{price} where order_detail_id = #{orderDetailId}")
    Integer update(OrderDetail orderDetail) throws Exception;

    /**
     * 根据订单编号查询订单明细
     * @param ordersId
     * @return
     * @throws Exception
     */
    List<OrderDetail> list(String ordersId) throws Exception;
}